package initialize

import (
	"github.com/gin-gonic/gin"
	"mxshop_api/goods_web/middlewares"
	"mxshop_api/goods_web/router"
	"net/http"
)

func InitRouter() *gin.Engine {
	Router := gin.Default()

	//consul健康检查
	Router.GET("/health", func(c *gin.Context){
		c.JSON(http.StatusOK, gin.H{
			"code":http.StatusOK,
			"success":true,
		})
	})

	//配置跨域
	Router.Use(middlewares.Cors())

	group := Router.Group("/v1")
	router.GoodsRouter(group)
	router.CategoryRouter(group)
	router.BannerRouter(group)
	router.BrandsRouter(group)

	return Router
}
